﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Wook1_for
{
    class Program
    {
        static void Main(string[] args)
        {
            double sum1= 1,sum2=1,sum3=1;
            double  i1=1,i2=1,i3;
            Console.WriteLine("使用While结构计算");
            while (i1<100) //使用while循环
            {
               sum1 += i1 / (i1 + 1);
               i1++; 
            }
            Console.WriteLine("1+1/2+2/3+…+99/100的结果:{0}",sum1);
            Console.WriteLine("使用do-While结构计算");
            do
            {
                sum2+= i2 / (i2 + 1);
                i2++;
            } while (i2<100);
            Console.WriteLine("1+1/2+2/3+…+99/100的结果:{0}", sum2);
            Console.WriteLine("使用for循环结构计算");
            for (i3=1;i3<100;i3++)
            {
                sum3 += i3 / (i3 + 1);
            }
            Console.WriteLine("1+1/2+2/3+…+99/100的结果:{0}", sum3);
            Console.ReadKey();
        }
    }
}
